import datetime
from cmsdj.haystack import indexes
from cmsdj.content.models import Content
#from cmsdj.haystack.fields import CharField, DateTimeField


class ContentIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    description = indexes.CharField (model_attr='description')
    title = indexes.CharField (model_attr='title')
#    pub_date = indexes.DateTimeField(model_attr='modified')
    modified = indexes.DateTimeField(model_attr='modified')

    def get_model(self):
        return Content

    def index_queryset(self):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.filter(modified__lte=datetime.datetime.now())
    